import java.util.Scanner;

public class Text1 {
    // DP34 【模版】前缀和
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(),q = sc.nextInt();
        int[] arr = new int[n+1];
        for (int i = 1; i < n+1; i++) {
            arr[i] = sc.nextInt();
        }

        long[] dp = new long[n+1];
        for (int i = 1; i < n + 1; i++) {
            dp[i] = dp[i-1] + arr[i];
        }

        while(q > 0){
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(dp[r] - dp[l-1]);
            q--;
        }
    }
}
